package com.zycfc.zsf.boot.office.pdf.generator;

import com.zycfc.zsf.boot.office.pdf.freemarker.*;
import java.io.*;
import freemarker.template.*;

public class HtmlGenerator
{
    public static String generate(final String template, final Object dataModel) throws Exception {
        final Configuration config = FreemarkerConfiguration.getConfiguation();
        final Template tp = config.getTemplate(template);
        final StringWriter stringWriter = new StringWriter();
        final BufferedWriter writer = new BufferedWriter(stringWriter);
        tp.setOutputEncoding("UTF-8");
        tp.process(dataModel, (Writer)writer);
        final String htmlStr = stringWriter.toString();
        writer.flush();
        writer.close();
        return htmlStr;
    }
}
